const {User} = require('../../model/user');

module.exports = async (req, res) => {
  req.app.locals.current = 'user';
  const {message, id} = req.query;
  // 修改操作
  if(id) {
    const user = await User.findOne({_id: id});
    console.log(user);
    res.render('admin/user-edit', {
      message: req.query.message,
      user,
      link: '/admin/user-modify?id=' + id,
      button: '修改'
    });
  }else {
    res.render('admin/user-edit', {
      message: req.query.message,
      link: '/admin/user-edit',
      button: '添加'
    });
  }

}